import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import vuexpersist from "vuex-persist";

export default new Vuex.Store({
  state: {
    list: [
    ],
  },
  mutations: {
    add(state,value){
      var fel=false
      state.list.forEach((c,i)=>{
        if(c.ojs==value){
          state.list.splice(i,1)
          state.list.push({
            ojs:value
          })
          fel=true
        }
      })

      if(fel==false){
        if(state.list.length<9){
          state.list.push({
            ojs:value
          })

        }else{
          state.list.shift()
          state.list.push({
            ojs:value
          })

        }
      }

     

    },
    remove(state){
      state.list=[]

    }
  },
  actions: {
  },
  modules: {
  },
  plugins:[
    new vuexpersist({
      storage:window.localStorage
    }).plugin
  ]
})
